You should read some book about DB structure design, then you will not have tables with such primary keys. Or hire someone who my create (prototype) for DB structure for you. This is just friendly advice.
(weblogs.asp. Net/alex_papadimoulis/archive/2005/05/25/…) – MGOwen Jun 9 '09 at 5:38.
PorneL has the correct answer for this case, however, @Cade Roux and @noonex are also correct: Databases are not meant to be used like Excel. You should have secondary tables: CREATE TABLE ServiceInstance ( ID int(11) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, Hash binary(16) NOT NULL, ServiceInstanceID varchar(100) NOT NULL, UNIQUE(Hash) ); For each table except data which will be unique per configuration line. When you insert, do: INSERT INTO ServiceInstance (Hash, ServiceInstanceID) VALUES (unhex(md5('whatever')), 'whatever'); Then, your primary table becomes: CREATE TABLE `configuration` ( `Section_ID` int unsigned NOT NULL, `StoredKey_ID` int unsigned NOT NULL, `ServiceName_ID` int unsigned NOT NULL, `ServiceMajorVersion` int unsigned NOT NULL, `ServiceMinorVersion` int unsigned NOT NULL, `ServiceInstanceID` int unsigned NOT NULL, `StoredValue` VARCHAR(1024), UNIQUE (`Section_ID`, `StoredKey_ID`, `ServiceName_ID`, `ServiceMajorVersion`, `ServiceMinorVersion`, `ServiceInstanceID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; Use the UNIQUE key instead, as PRIMARY KEYs are typically used when you will be accessing the rows by the primary key always.
If it's just a constraint, use UNIQUE instead.
Use autoincremented integer for primary key and add another unique key. Alternatively you could try using binary(16) as primary key with unhex(md5(concat(columns))) as value.
2 "Just chuck an autoincrementing integer PK on it" is not always the answer to a database design problem, despite what many people seem to think. In this case, it will only hide much deeper problems in this schema, and furthermore will be completely useless for enforcing appropriate uniqueness constraints. – kquinn Jun 9 '09 at 5:40 @kquinn: Of course.
I'm just answering how to work with long PK assuming one has good reason to use it. – porneL Jun 16 '09 at 12:22.
It's hard to say without understanding your database, but it might need some normalization. You could always make a UNIQUE INDEX that is not a primary key, and if there is already a single column which will be unique, make that a primary key, and if there is not, you can make a surrogate primary key (INTEGER AUTO_INCREMENT).
Agree with what @pornel and @CadeRoux already posted; you would be better off creating a surrogate primary key (ConfigurationId) as an autoincremented integer column, an dthen create separate unique index.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.